

from base.base import Base
from selenium.webdriver.common.by import By
from time import sleep

class FirstAddPage(Base):

    goodsmanager = (By.XPATH, '//span[text()="商场管理"]')
    def clickgoodsmanager(self):
        self.loc_ele(self.goodsmanager).click()

    manufacturer = (By.XPATH, '//span[text()="品牌制造商"]')
    def clickmanufacturer(self):
        self.loc_ele(self.manufacturer).click()

    addbrand = (By.CSS_SELECTOR,"#app > div > div.main-container > section > div > div.filter-container > button:nth-child(4) > span")
    def clickaddbrand(self):
        self.loc_ele(self.addbrand).click()

    inputbrand = (By.XPATH,"/html/body/div[1]/div/div[2]/section/div/div[4]/div/div[2]/form/div[1]/div/div[1]/input")
    def inputname(self,c):
        ele = self.loc_ele(self.inputbrand)
        ele.send_keys(c)
    introduce = (By.CSS_SELECTOR,"#app > div > div.main-container > section > div > div.el-dialog__wrapper > div > div.el-dialog__body > form > div:nth-child(2) > div > div > input")
    def inputintorduce(self,c):
        ele = self.loc_ele(self.introduce)
        ele.send_keys(c)
    price = (By.CSS_SELECTOR,"#app > div > div.main-container > section > div > div.el-dialog__wrapper > div > div.el-dialog__body > form > div:nth-child(4) > div > div > input")
    def inputprice(self,c):
        ele = self.loc_ele(self.price)
        ele.send_keys(c)

    ensurebutton = (By.XPATH, '/html/body/div[1]/div/div[2]/section/div/div[4]/div/div[3]/div/button[2]/span')
    def clickensurebutton(self):
        self.loc_ele(self.ensurebutton).click()

    dy = (By.XPATH, '/html/body/div[3]/div/div[1]/p')
    def getdycontent(self):
        return self.loc_ele(self.dy).text


    def firstadd(self,n,m,p):
        self.clickgoodsmanager()
        sleep(1)
        self.clickmanufacturer()
        sleep(1)
        self.clickaddbrand()
        self.inputname(n)
        self.inputintorduce(m)
        self.inputprice(p)
        self.ensurebutton()
        sleep(3)
